﻿using System;

namespace Bootstrap5;

/// <summary>
/// Define a toast service.
/// </summary>
public interface IToastService
{
    void Show(Action<ToastOptions> optionAction);
    event Action<ToastOptions> OnShow;
}

/// <summary>
/// The default implementation of <see cref="IToastService"/> .
/// </summary>
internal class ToastService : IToastService
{
	public event Action<ToastOptions> OnShow;

	/// <summary>
	/// Show toast within specify options.
	/// </summary>
	/// <param name="optionAction"></param>
	public void Show(Action<ToastOptions> optionAction)
	{
		var options = new ToastOptions();
		optionAction(options);
		OnShow(options);
	}
}
